<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript">
	function search(){
		var con_NO = $("#contractNo").val();
		var url = "http://localhost:8080/jk/cxf/wsContractService?wsdl";
		var requestData = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" " + 
		" xmlns:q0=\"http://ws.service.jk.lifeng.com/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"  " + 
		  " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
		"<soapenv:Body>" +
		"<q0:getWsContractInfo>" +
			"<arg0>"+con_NO+"</arg0>" +
		"</q0:getWsContractInfo>" +
		"</soapenv:Body>" +
		"</soapenv:Envelope>";
		/* var option = {
				url:"http://localhost:8080/jk/cxf/wsContractService",
				type:"post",
				dataType:"text",
				contentType:"text/xml;charset=UTF-8",
				data:requestData,
				success:function(responseText){
					alert("成功");
				},
				error:function(){
					//如果ajax发生url错误404或者后台代码发生异常会走到error里面
					alert("系统错误");
				}
		};
		$.ajax(option); */
		$("#customName").empty();
		$("#signingDate").empty();
		$("#totalAmount").empty();
		$("#contractNox").empty();
		$("#remark").empty();
		var xhr = new ActiveXObject("Microsoft.XMLHTTP");
		xhr.open("POST", url);
		xhr.onreadystatechange = _back;						//设置回调的函数
		xhr.send(requestData);								//请求的soap xml
		function _back(){
			if(xhr.readystate==4){								//处理完成
				if(xhr.status==200){
					var xml = xhr.responseXML;
					var xml = $(xml);
					
					
					$("#data").show();
					xml.find("return").each(function(){
						$("#customName").append($(this).find("customName").text());
						$("#signingDate").append($(this).find("signingDate").text().substring(0,10));
						$("#totalAmount").append($(this).find("totalAmount").text());
						$("#contractNox").append($(this).find("contractNo").text());
						$("#remark").append($(this).find("remark").text());
					});
				}else{
					alert('此合同不存在');
				}
			}
			
		}
	}
</script>
</head>
<body>
合同号:<input type="text" id="contractNo"/><button onclick="search();">查询</button><br/>
	<div id="data" style="display: none;">
		客户:<span id="customName"></span>	<br/>
		签单日期:<span id="signingDate"></span>	<br/>
		总金额:<span id="totalAmount"></span>	<br/>
		合同号:<span id="contractNox"></span>	  <br/>
		说明:<span id="remark"></span>	<br/>
	</div>
</body>
</html>